<template>
  <div class="c-pagination" v-if="total">
    <div @click="handleClick(1)" class="pointer" :class="{'c-pagination-disabled':page === 1}"><i class="el-icon-d-arrow-left"></i></div>
    <div @click="handleClick(page - 1)" class="pointer" :class="{'c-pagination-disabled':page === 1}"><i class="el-icon-arrow-left"></i></div>
    <div>{{ page }}</div>
    <div>/</div>
    <div>{{ total }}</div>
    <div @click="handleClick(page + 1)" class="pointer" :class="{'c-pagination-disabled':page === total}"><i class="el-icon-arrow-right"></i></div>
    <div @click="handleClick(total)" class="pointer" :class="{'c-pagination-disabled':page === total}"><i class="el-icon-d-arrow-right"></i></div>
  </div>
</template>

<script>
export default {
  name: "cPagination",
  components: {},
  mixins: [],
  props: {
    total: {
      type: Number,
      default: 0
    },
    page: {
      type: Number,
      default: 1
    }
  },
  data () {
    return {}
  },
  computed: {},
  watch: {},
  filter: {},
  created () { },
  mounted () { },
  methods: {
    handleClick(page) {
      if (page > 0 && page <= this.total) {
        this.$emit("changePage", page)
      }
    }
  },
}
</script>
<style lang='scss' scoped>
.c-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size:14px;
}
.pointer {
  cursor: pointer;
  &.c-pagination-disabled {
    cursor: not-allowed;
    color: #a3b0cc;
  }
}
</style>
